package com.mayikt.edu.controller;

import com.mayikt.edu.base.BaseApiController;
import com.mayikt.edu.domain.EduUser;
import com.mayikt.edu.service.EduUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (EduUser)表控制层
 *
 * @author wangjin
 * @since 2023-10-30 09:22:58
 */
@Api(value = "", tags = "")
@RestController
@RequestMapping("eduUser")
@Slf4j
public class EduUserController extends BaseApiController {
    /**
     * 服务对象
     */
    @Resource
    private EduUserService eduUserService;

    @PutMapping("/findByUserNameEduUser")
    public EduUser findByUserNameEduUser(String userName) {
        return eduUserService.findByUserNameEduUser(userName);
    }

    /**
     * 编辑数据
     *
     * @param eduUser 实体
     * @return 编辑结果
     */

    @ApiOperation("编辑数据")
    @PutMapping
    public ResponseEntity<EduUser> edit(@RequestBody EduUser eduUser) {
        return ResponseEntity.ok(this.eduUserService.update(eduUser));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */

    @ApiOperation("删除数据")
    @DeleteMapping("/{id}")
    public ResponseEntity<Boolean> deleteById(@PathVariable Long id) {
        return ResponseEntity.ok(this.eduUserService.deleteById(id));
    }

}

